package com.mycinema.biz.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.mycinema.biz.CategoryBiz;
import com.mycinema.dao.CategoryDao;
import com.mycinema.entity.Category;

@Service("categoryBiz")
@Scope("prototype")

@Transactional(propagation = Propagation.REQUIRED)

public class CategoryBizImpl implements CategoryBiz {

	@Autowired

	private CategoryDao categoryDao;

	@Transactional(readOnly = true)
	public List<Category> getAll() {
		return categoryDao.getAll();
	}

	public static void main(String[] args) {
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
				"beans.xml");
		CategoryBiz categoryBiz = (CategoryBiz) applicationContext
				.getBean("categoryBiz");
		categoryBiz.getAll();
		System.out.println("ok");

	}

	public void addCategory(Category category) {
		// TODO Auto-generated method stub
		categoryDao.addCategory(category);
	}

}
